package top.lyjwn.ajui.widget.botton;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatButton;
import top.lyjwn.ajui.R;
import top.lyjwn.ajui.util.RoundUtil;

/**
 * 圆角按钮
 *
 * @author luoyujie
 */
public class RoundButton extends AppCompatButton {


    public RoundButton(Context context) {
        this(context,null);
    }

    public RoundButton(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        RoundUtil.clipViewCornerByDp(this,15);
        setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        setAlpha(0.5f);
                        break;
                    case MotionEvent.ACTION_UP:
                        setAlpha(1);
                        break;
                }
                return false;
            }
        });
    }

}
